package com.wlf.generate.entity;

public class DataBase {

    private static String MYSQL_URL = "jdbc:mysql://[ip]:[port]/[db]?useUnicode=true&characterEncoding=utf8";

    /**
     * 数据库类型
     */
    private String dbType;

    private String driver;

    private String userName;

    private String password;

    private String url;

    public DataBase() {
    }

    public DataBase(String dbType) {
        this(dbType,"127.0.0.1","3306","");
    }
    public DataBase(String dbType,String db) {
        this(dbType,"127.0.0.1","3306",db);
    }

    /**
     *
     * @param dbType
     * @param ip
     * @param port
     * @param db 数据库
     */
    public DataBase(String dbType,String ip,String port,String db) {
        this.dbType = dbType;
        this.driver = "com.mysql.jdbc.Driver";
        this.url = MYSQL_URL.replace("[ip]",ip).replace("[port]",port).
                replace("[db]",db);
    }


    public String getDbType() {
        return dbType;
    }

    public void setDbType(String dbType) {
        this.dbType = dbType;
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
